﻿using System.Web.Mvc;
using Data;
using Models;

namespace Web.Controllers
{
    public class RegController : BaseController
    {
        //
        // GET: /Reg/

        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Index(RegModel model,int Role)
        {
            if (ModelState.IsValid)
            {
                var dbUsers = new UsersData();
                dbUsers.AddUser( 
                    new Users{
                        Name = model.Name,
                        FName = model.FName,
                        MName = model.MName,
                        Login = model.Login,
                        Pwd = model.Pwd,
                        Email = model.Email,
                        Role = Role
                    });

                ViewBag.Message = "Registration was successful";
                return View("Thanks");
            }
            
            return View(model);
            
        }

    }
}
